-- ----------------------------
-- Table structure for order_items
-- ----------------------------
DROP TABLE IF EXISTS `order_items`;
CREATE TABLE `order_items` (
  `id` varchar(64) NOT NULL COMMENT '主键id',
  `order_id` varchar(64) NOT NULL COMMENT '归属订单id',
  `item_id` varchar(64) NOT NULL COMMENT '商品id',
  `item_img` varchar(128) NOT NULL COMMENT '商品图片',
  `item_name` varchar(128) NOT NULL COMMENT '商品名称',
  `item_spec_id` varchar(32) NOT NULL COMMENT '规格id',
  `item_spec_name` varchar(32) NOT NULL COMMENT '规格名称',
  `price` int(11) NOT NULL COMMENT '成交价格',
  `buy_counts` int(11) NOT NULL COMMENT '购买数量',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='订单商品关联表 ';

-- ----------------------------
-- Records of order_items
-- ----------------------------
BEGIN;
INSERT INTO `order_items` VALUES ('230913GTXNN3RY5P', '230913GTXNMRG9AW', 'bingan-1002', 'https://ailbin-1302692288.cos.ap-guangzhou.myqcloud.com/foodie/bingan-1002/img1.png', '【小鹅饼饼】男人最爱 秋葵饼干 嘎嘣脆', 'bingan-1002-spec-1', '巧克力', 13500, 1);
INSERT INTO `order_items` VALUES ('230913GZYW56XXGD', '230913GZYW56XXGC', 'bingan-1005', 'https://ailbin-1302692288.cos.ap-guangzhou.myqcloud.com/foodie/bingan-1005/img1.png', '【小鹅饼饼】夹心吐司面包 早餐面包 早点早饭', 'bingan-1005-spec-1', '巧克力', 19800, 1);
INSERT INTO `order_items` VALUES ('231015C1YY1NG3F8', '231015C1YY1CP1KP', 'bingan-1003', 'https://ailbin-1302692288.cos.ap-guangzhou.myqcloud.com/foodie/bingan-1003/img1.png', '【小鹅饼饼】可爱动物饼干 儿童早餐 孩子最爱', 'bingan-1003-spec-1', '巧克力', 9000, 1);
COMMIT;

-- ----------------------------
-- Table structure for order_status
-- ----------------------------
DROP TABLE IF EXISTS `order_status`;
CREATE TABLE `order_status` (
  `order_id` varchar(64) NOT NULL COMMENT '订单ID;对应订单表的主键id',
  `order_status` int(11) NOT NULL COMMENT '订单状态：10-待付款，20-已付款，待发货，30-已发货，待收货，40-交易成功，50-交易关闭',
  `created_time` datetime DEFAULT NULL COMMENT '订单创建时间;对应[10:待付款]状态',
  `pay_time` datetime DEFAULT NULL COMMENT '支付成功时间;对应[20:已付款，待发货]状态',
  `deliver_time` datetime DEFAULT NULL COMMENT '发货时间;对应[30：已发货，待收货]状态',
  `success_time` datetime DEFAULT NULL COMMENT '交易成功时间;对应[40：交易成功]状态',
  `close_time` datetime DEFAULT NULL COMMENT '交易关闭时间;对应[50：交易关闭]状态',
  `comment_time` datetime DEFAULT NULL COMMENT '留言时间;用户在交易成功后的留言时间',
  PRIMARY KEY (`order_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='订单状态表;订单的每个状态更改都需要进行记录\n10：待付款  20：已付款，待发货  30：已发货，待收货（7天自动确认）  40：交易成功（此时可以评价）50：交易关闭（待付款时，用户取消 或 长时间未付款，系统识别后自动关闭）\n退款/退货，此分支流程不做，所以不加入';

-- ----------------------------
-- Records of order_status
-- ----------------------------
BEGIN;
INSERT INTO `order_status` VALUES ('230913GTXNMRG9AW', 10, '2023-09-13 22:12:52', NULL, NULL, NULL, NULL, NULL);
INSERT INTO `order_status` VALUES ('230913GZYW56XXGC', 10, '2023-09-13 22:25:00', NULL, NULL, NULL, NULL, NULL);
INSERT INTO `order_status` VALUES ('231015C1YY1CP1KP', 20, '2023-10-16 00:54:43', '2023-10-16 00:54:55', NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for orders
-- ----------------------------
DROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders` (
  `id` varchar(64) NOT NULL COMMENT '订单主键;同时也是订单编号',
  `user_id` varchar(64) NOT NULL COMMENT '用户id',
  `receiver_name` varchar(32) NOT NULL COMMENT '收货人快照',
  `receiver_mobile` varchar(32) NOT NULL COMMENT '收货人手机号快照',
  `receiver_address` varchar(128) NOT NULL COMMENT '收货地址快照',
  `total_amount` int(11) NOT NULL COMMENT '订单总价格',
  `real_pay_amount` int(11) NOT NULL COMMENT '实际支付总价格',
  `post_amount` int(11) NOT NULL COMMENT '邮费;默认可以为零，代表包邮',
  `pay_method` int(11) NOT NULL COMMENT '支付方式',
  `left_msg` varchar(128) DEFAULT NULL COMMENT '买家留言',
  `extand` varchar(32) DEFAULT NULL COMMENT '扩展字段',
  `is_comment` int(11) NOT NULL COMMENT '买家是否评价;1：已评价，0：未评价',
  `is_delete` int(11) NOT NULL COMMENT '逻辑删除状态;1: 删除 0:未删除',
  `created_time` datetime NOT NULL COMMENT '创建时间（成交时间）',
  `updated_time` datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='订单表;';

-- ----------------------------
-- Records of orders
-- ----------------------------
BEGIN;
INSERT INTO `orders` VALUES ('230913GTXNMRG9AW', '230907BCFM80SAY8', '牙牙乐', '18682449803', '广东深圳龙岗区光雅园', 15000, 13500, 0, 1, '', NULL, 0, 0, '2023-09-13 22:12:51', '2023-09-13 22:12:51');
INSERT INTO `orders` VALUES ('230913GZYW56XXGC', '230907BCFM80SAY8', '牙牙乐', '18682449803', '广东深圳龙岗区光雅园', 22000, 19800, 0, 2, '', NULL, 0, 0, '2023-09-13 22:24:59', '2023-09-13 22:24:59');
INSERT INTO `orders` VALUES ('231015C1YY1CP1KP', '230907BCFM80SAY8', '牙牙乐', '18682449803', '广东深圳龙岗区光雅园', 10000, 9000, 0, 1, '', NULL, 0, 0, '2023-10-16 00:54:43', '2023-10-16 00:54:43');
COMMIT;

-- ----------------------------
-- Table structure for pay_orders
-- ----------------------------
DROP TABLE IF EXISTS `pay_orders`;
CREATE TABLE `pay_orders` (
  `id` varchar(50) NOT NULL COMMENT '主键ID',
  `merchant_user_id` varchar(50) DEFAULT NULL COMMENT '订单号',
  `merchant_order_id` varchar(50) NOT NULL COMMENT '用户ID',
  `amount` int(20) NOT NULL COMMENT '支付金额，单位：分',
  `pay_method` int(10) DEFAULT NULL COMMENT '支付平台：1-微信，2-支付宝',
  `pay_status` int(20) DEFAULT NULL COMMENT '支付状态：10：未支付 20：已支付 30：支付失败 40：已退款',
  `come_from` varchar(200) DEFAULT NULL COMMENT '来源',
  `return_url` varchar(200) DEFAULT NULL COMMENT '成功请求url路径',
  `is_delete` int(20) DEFAULT NULL COMMENT '逻辑删除状态;1: 删除 0:未删除',
  `create_time` datetime DEFAULT current_timestamp() COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `que_omerchant_order_id` (`merchant_order_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 ROW_FORMAT=COMPACT COMMENT='商户订单';

-- ----------------------------
-- Records of pay_orders
-- ----------------------------
BEGIN;
INSERT INTO `pay_orders` VALUES ('230913GTXR10WW4H', '230907BCFM80SAY8', '230913GTXNMRG9AW', 1, 1, 20, '小鹅拼拼', 'http://47.106.83.33:8088/payment/createMerchantOrder', 0, '2023-09-13 22:12:52');
INSERT INTO `pay_orders` VALUES ('230913GZYX5R8R68', '230907BCFM80SAY8', '230913GZYW56XXGC', 1, 2, 10, '小鹅拼拼', 'http://47.106.83.33:8088/payment/createMerchantOrder', 0, '2023-09-13 22:25:00');
INSERT INTO `pay_orders` VALUES ('231015C1YYAP0HZC', '230907BCFM80SAY8', '231015C1YY1CP1KP', 1, 1, 20, '小鹅拼拼', 'http://47.106.83.33:8088/orders/notifyMerchantOrderPaid', 0, '2023-10-16 00:54:43');
COMMIT;